-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add backup attribute to file resource (close #124) #191
base: master
Are you sure you want to change the base?
Add backup attribute to file resource (close #124) #191
Conversation
b8ebe41
to
0679caa
Compare
|
af1e2d0
to
e40a5c2
Compare
@ryotarai Following error occured in Werker at
|
@@ -169,6 +176,34 @@ def send_tempfile | |||
f.unlink if f | |||
end | |||
end | |||
|
|||
def backup | |||
return unless (attributes.backup).kind_of?(FalseClass) ? false : attributes.backup > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the following is simpler
return if !attributes.backup || attributes.backup <= 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I'll fix it.
e40a5c2
to
e1359a1
Compare
backup_files = run_command(['ls', '-1', backup_directory]) | ||
backup_files = backup_files.stdout.chomp.split("\n").select { |f| | ||
f.match(/\A#{basename}.itamae-[0-9]+\z/) | ||
}.reverse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I use run_command("ls -1 #{::File.join(BACKUP_PATH, attributes.path + '.itamae-*')}")
?
(When I use ['ls', '-1', ::File.join(BACKUP_PATH, attributes.path + '.itamae-*']
, *
is escaped to \*
and can't execute.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current implementation is good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thank you!
0d72069
to
b9224b9
Compare
@ryotarai I apologize for my late reply.
|
Okay. It is better that |
@ryotarai And |
As you said, Specinfra doesn't have sufficient commands for this PR but you can send a PR to https://github.com/mizzy/specinfra |
@ryotarai OK! I try to send PR to Specinfra. |
b9224b9
to
854962a
Compare
@ryotarai I fixed by using Specinfra v2.54.0! |
854962a
to
02b3d42
Compare
Add
backup
attribute tofile
(alsoremote_file
,template
andhttp_request
).This is the number of backups to be kept in
/var/itamae/backup
(default is5
.)backup
method is based on chef/lib/chef/deprecation/provider/file.rb.(This attribute is same as file of Chef.)
For example:
(In this case, file is backed up to
/var/itamae/backup/tmp/file.itamae-20160114001759
.)